﻿using System;
using System.IO;
using ApprovalTests;
using ApprovalTests.Reporters;
using ApprovalUtilities.Utilities;
using Microsoft.SmallBasic.Library;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SmallBasicFun.Tests
{
	[TestClass]
	[UseReporter(typeof(DiffReporter))]
	public class ParserTest
	{
		[TestMethod]
		public void TestParser()
		{
			Primitive wordList = "";
			wordList["girlFriend"] = "Lynn";
			wordList["rating"] = "Amazing";
			Approvals.Verify(Parser.Merge("{girlFriend} is {rating} {rating} {rating}!!!",wordList));
		}

		[TestMethod]
		public void TestParserRtf()
		{
			Primitive wordList = "";
			wordList["exclamation"]	= "Holy Guacamole Paste";
			wordList["adverb"]			= "Fabulously";
			wordList["noun"]				= "beard";
			wordList["adjective"]		=	"metallic";
			var mergeRtfFile = Parser.MergeRtfFile(PathUtilities.GetDirectoryForCaller() + "madlib.rtf", wordList);
			ApproveRtfFile(mergeRtfFile);
		}
		[TestMethod]
		public void TestMissingFields()
		{
			Primitive wordList = "";
			wordList["girlFriend"] = "Lynn";
			Approvals.Verify(Parser.Merge("{girlFriend} is {rating} {rating} {rating}!!!", wordList));
		}

		

		public static void ApproveRtfFile(Primitive mergeRtfFile)
		{
			Approvals.Verify(new ApprovalTextWriter(mergeRtfFile, "rtf"), new ApprovalTests.Namers.UnitTestFrameworkNamer(), new FileLauncherReporter());
		}
	}
}
